package com.dg.cuckoo.admin.action.projectInfo;

import com.dg.cuckoo.admin.dto.projectInfo.ProjectLogDto;
import com.dg.cuckoo.admin.service.ProjectLogService;
import com.dg.cuckoo.common.utils.PageModel;
import com.dg.cuckoo.core.BaseController;
import com.dg.cuckoo.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 项目信息-项目日志
 */
@RestController
@RequestMapping("/projectInfo/projectLog")
public class ProjectLog extends BaseController {

    @Autowired
    private ProjectLogService service;

    /**
     * 新增 save
     */
    @PostMapping("save")
    public JsonResult<Void> save(ProjectLogDto dto, MultipartFile[]files, String projectId) throws Exception {
        service.save(dto,files,projectId);
        return new JsonResult<>(OK);
    }

    /**
     * 删除
     * @param id 项目日志id
     * @return
     */
    @PostMapping("delect/{id}")
    public JsonResult<Void> delect(@PathVariable String id){
        service.delect(id);
        return new JsonResult<>(OK);
    }


    /**
     * 分页
     */
    @PostMapping("page/{page}/{pageSize}/{id}")
    public JsonResult<PageModel> page(@PathVariable Integer page, @PathVariable Integer pageSize, @PathVariable String id){
        PageModel data = service.page(page, pageSize,id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击序号显示所有项目日志所有信息
     * @param id 项目日志id
     * @return
     */
    @PostMapping("openSerialInfo/{id}")
    public JsonResult<String> openSerialInfo(@PathVariable String id){
        String data = service.openSerialInfo(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 点击发文字号显示文本框
     */
    @PostMapping("openTextNumberInfo")
    public JsonResult<String> openTextNumberInfo(String id){
        String data = service.openTextNumberInfo(id);
        return new JsonResult<>(OK,data);
    }

    /**
     * 编辑
     */
    @PostMapping("updata/{id}")
    public JsonResult<Void> updata(@PathVariable String id,String projectId,ProjectLogDto dto,MultipartFile[]files) throws Exception {
        service.updata(id,projectId,dto,files);
        return new JsonResult<>(OK);
    }
}
